﻿<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Magick++ API: Working with Blobs</title>
    <link rel="stylesheet" href="magick.css" type="text/css" />
</head>
<body>
    <div class="doc-section">
        <h1 align="center">Magick::Blob</h1>
        <p>Blob provides the means to contain any opaque data. It is named after the term "Binary Large OBject" commonly used to describe unstructured data (such as encoded images) which is stored in a database. While the function of Blob is very simple (store a pointer and size associated with allocated data), the Blob class provides some very useful capabilities. In particular, it is fully reference counted just like the Image class.</p>
        <p>The Blob class supports value assignment while preserving any outstanding earlier versions of the object. Since assignment is via a pointer internally, Blob is efficient enough to be stored directly in an STL container or any other data structure which requires assignment. In particular, by storing a Blob in an <a href="http://www.sgi.com/tech/stl/AssociativeContainer.html">associative container</a> (such as STL's '<a href="http://www.sgi.com/tech/stl/Map.html"><i>map</i></a>') it is possible to create simple indexed in-memory "database" of Blobs.</p>
        <p>Magick++ currently uses Blob to contain encoded images (e.g. JPEG) as well as ICC and IPTC profiles. Since Blob is a general-purpose class, it may be used for other purposes as well.</p>
        <p style="margin-bottom: 0cm">The methods Blob provides are shown in the following table:</p>
        <br />
        <p align="center" style="margin-bottom: 0cm"><b>Blob Methods</b></p>
        <table width="100%" border="1" cellpadding="2" cellspacing="2">
            <tr>
                <td>
                    <p align="center"><b>Method</b></p>
                </td>
                <td>
                    <p align="center"><b>Return Type</b></p>
                </td>
                <td>
                    <p align="center"><b>Signature(s)</b></p>
                </td>
                <td>
                    <p align="center"><b>Description</b></p>
                </td>
            </tr>
            <tr>
                <td rowspan="3">
                    <p><a name="Blob"></a><font size="2">Blob</font></p>
                </td>
                <td rowspan="3" bgcolor="#666666"></td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">Default constructor</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><font size="2">const void* data_, size_t length_</font></p>
                </td>
                <td>
                    <p><font size="2">Construct object with data, making a copy of the supplied data</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><font size="2">const Blob&amp; blob_</font></p>
                </td>
                <td>
                    <p><font size="2">Copy constructor (reference counted)</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><a name="operator="></a><font size="2">operator=</font></p>
                </td>
                <td>
                    <p><font size="2">Blob</font></p>
                </td>
                <td>
                    <p><font size="2">const Blob&amp; blob_</font></p>
                </td>
                <td>
                    <p><font size="2">Assignment operator (reference counted)</font></p>
                </td>
            </tr>
            <tr>
                <td rowspan="2">
                    <p><a name="base64"></a><font size="2">base64</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">const std::string base64_</font></p>
                </td>
                <td>
                    <p><font size="2">Update object contents from Base64-encoded string representation.</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><font size="2">std::string</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">Return Base64-encoded string representation.</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><a name="data"></a><font size="2">data</font></p>
                </td>
                <td>
                    <p><font size="2">const void*</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">Obtain pointer to data. The user should never try to modify or free this data since the Blob class manages its own data. The user must be finished with the data before allowing the Blob to be destroyed since the pointer is invalid once the Blob is destroyed.</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><a name="length"></a><font size="2">length</font></p>
                </td>
                <td>
                    <p><font size="2">size_t</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">Obtain data length.</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><a name="update"></a><font size="2">update</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">const void* data_, size_t length_</font></p>
                </td>
                <td>
                    <p><font size="2">Update object contents, making a copy of the supplied data. Any existing data in the object is deallocated.</font></p>
                </td>
            </tr>
            <tr>
                <td>
                    <p><a name="updateNoCopy"></a><font size="2">updateNoCopy</font></p>
                </td>
                <td>
                    <p><font size="2">void</font></p>
                </td>
                <td>
                    <p><font size="2">void* data_, size_t length_, Blob::Allocator allocator_ = Blob::NewAllocator</font></p>
                </td>
                <td>
                    <p><font size="2">Update object contents, using supplied pointer directly (no copy) Any existing data in the object is deallocated. The user must ensure that the pointer supplied is not deleted or otherwise modified after it has been supplied to this method. The optional allocator_ parameter allows the user to specify if the C (MallocAllocator) or C++ (NewAllocator) memory allocation system was used to allocate the memory. The default is to use the C++ memory allocator.</font></p>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
